package com.ray.util.baidu;

import com.baidu.aip.imagesearch.AipImageSearch;

/**
 * 
 * @author Shensg
 * AipImageSearch是图像搜索的Java客户端，为使用图像搜索的开发人员提供了一系列的交互方法。
 * 2018年10月5日
 * 
 */
public class AipImageSearchUtil {
	//设置APPID/AK/SK
    public static final String APP_ID = "14311829";
    public static final String API_KEY = "WDwgu5VgA8NsV8L59A8BfKFw";
    public static final String SECRET_KEY = "k6tVFUKQvsYYBS8rHXEIMD7wgSOwY9YO";
    
    public static AipImageSearch aipImageSearch ;
    
    public AipImageSearchUtil()  {
		throw new RuntimeException("此类不允许被new");
	}
    
    public static AipImageSearch getConfig() {
    	if (aipImageSearch == null) {
    		 // 初始化一个AipImageSearch
    		aipImageSearch = new AipImageSearch(APP_ID, API_KEY, SECRET_KEY);
    		aipImageSearch.setConnectionTimeoutInMillis(1000);
		}
    	return aipImageSearch;
    }
    
    public static void main(String[] args) {
    	String sqlCheckDynamicQrcode =""
				+ "select "
				+ "order_id as orderId,"
				+ "qr_no    as qrNo,"
				+ "qr_type  as qrType, "
				+ "CASE "
					+ "WHEN ( "
					+ "	total_quantity - cancel_quantity - check_quantity > 0 "
					+ ") "
					+ "THEN 1 "
					+ "ELSE 0 "
				+ "END AS quantityLimit, "
				+ "CASE "
					+ "WHEN (end_time > now()) THEN	1 "
					+ "ELSE	0 "
				+ "End AS timeLimit, "
				+ "(select goods_type from goods_def g where g.row_id = o.pro_id) as goodsType "
				+ "from "
				+ "order_info "
				+ "where "
				+ "order_id = ? "
				+ "and uid = ? " ;
    	System.out.println(sqlCheckDynamicQrcode);
	}
}
